<template>
  <div class="total-container">
    <div class="common-tab-box">
      <div
        class="tab"
        v-for="item in tabs"
        :class="{ 'active': currentSelectedId === item.id }"
        :key="item.id"
        @click="handleClick(item.id)"
      >
        {{ item.text }}
      </div>
    </div>
    <component :is="compName"></component>
  </div>
</template>
<script>
import climateEnvironment from './tabComp/climateEnvironment.vue'
import naturalResources from './tabComp/naturalResources.vue'
export default {
  data() {
    return {
      tabs: [
        { text: '气候环境', id: 0, compName: 'climateEnvironment' },
        { text: '自然资源', id: 1, compName: 'naturalResources' }
      ],
      currentSelectedId: 1,
      compName: 'naturalResources'
    }
  },
  components: {
    climateEnvironment,
    naturalResources
  },
  methods: {
    handleClick(id) {
      this.currentSelectedId = id
      this.compName = this.tabs[id].compName
    }
  }
}
</script>
<style lang="scss" scoped>
.total-container {
  height: 90%;
}
</style>
